package android.bignerdranch.xiangmu;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class Main extends AppCompatActivity implements View.OnClickListener {

    private static final String PREFS_NAME ="android.bignerdranch.xiangmu" ;
    Button bt_mes;
    Button bt_get_score;
    Button bt_show_score;
    Button bt_un_login;
    SharedPreferences sharedPreferences;
    SharedPreferences.Editor editor;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Init();

    }

    void Init()
    {
        bt_mes=findViewById(R.id.main_get_mes);
        bt_get_score=findViewById(R.id.main_qdpf);
        bt_show_score = findViewById(R.id.main_fsck);
        bt_un_login = findViewById(R.id.main_un_login);
        bt_mes.setOnClickListener(this);
        bt_get_score.setOnClickListener(this);
        bt_show_score.setOnClickListener(this);
        bt_un_login.setOnClickListener(this);
        sharedPreferences = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
        editor = sharedPreferences.edit();
        editor.apply();
    }

    @Override
    public void onClick(View v) {
        final int bt_un_login = R.id.main_un_login;
        final int bt_mes = R.id.main_get_mes;
        final int bt_get_score = R.id.main_qdpf;
        final int bt_show_score = R.id.main_fsck;
        switch (v.getId())
        {
            case bt_mes:
            {
                Intent intent1 = new Intent();
                intent1.setClass(Main.this,MessageSave.class);
                startActivity(intent1);
                break;
            }
            case bt_un_login:
            {
                editor.putInt("auto", 0);
                editor.apply();
                Intent intent = new Intent();
                intent.setClass(Main.this,Login.class);
                startActivity(intent);
                break;
            }
            case bt_get_score:
            {
                Intent intent = new Intent();
                intent.setClass(Main.this,QDscore.class);
                startActivity(intent);
                break;
            }
            case bt_show_score:
            {
                Intent intent = new Intent();
                intent.setClass(Main.this,ClassesScore.class);
                startActivity(intent);
                break;
            }
        }

    }
}
